<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="id" label="编号" width="180"> </el-table-column>
      <el-table-column prop="province" label="省" width="180">
      </el-table-column>
      <el-table-column prop="city" label="市"> </el-table-column>
      <el-table-column prop="area" label="区/县"> </el-table-column>
      <el-table-column prop="address" label="街道"> </el-table-column>
      <el-table-column prop="telephone" label="手机号"> </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  mounted() {
    var id = this.id;
    var self = this;
    this.$axios
      .get("/order/query", { params: { customerId: id } })
      .then((res) => {
        console.log(res.data.data);
        res.data.data.forEach((item, index) => {
          self.tableData.push(item.address);
        });
        //调用去重
        this.unique();
      });
  },
  data() {
    return {
      tableData: [],
    };
  },
  props: ["id"],
  methods: {
    //去除重复的数组
    unique() {
      var data = [];
      var id = [];
      this.tableData.forEach((item, index) => {
        if (item != null) {
          if (id.indexOf(item.id) == -1) {
            data.push(item);
            id.push(item.id);
          }
        }
      });
      console.log(data);
      this.tableData = data;
    },
  },
};
</script>